<?php 
namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
	protected $table = 'article';

	protected $fillable = ['title',  'body', 'click_num'];

	public static function Add_Article($data)
	{
		return Article::create($data);
	}

	public static function Get_Article($Wid)
	{
		return Article::find($Wid);
	}

	public static function Get_list_page(){
		return Article::where('deleted_at', '=', 0)->select('id', 'title')->paginate(20);
	}

	public static function Add_Click($id){
		return Article::where('id', '=', $id)->increment('click_num');
	}

	public function freshTimestamp()
	{
        		return time();
    	}

    	public function fromDateTime($value)
    	{
        		return $value;
    	}

    	public function getDateFormat()
    	{
        		return 'U';
    	}
}